<template>
  <div>
    <BreakSpace label="车辆信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel1" :list="formList1" :cols="4" :formType="'add'" labelWidth="100" :isSubmitBtn="false" @formChange="formChangeHandle1"/>
    <div style="padding-top: 3rem;"></div>

    <BreakSpace label="车主信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel2" :list="formList2" :cols="4" :formType="'add'" labelWidth="90" :isSubmitBtn="false" @formChange="formChangeHandle2" />
    <div style="padding-top: 3rem;"></div>

    <BreakSpace label="附件信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel3" :list="formList3" :cols="2" :labelWidth="140" :isSubmitBtn="false" :formType="'add'" @formChange="formChangeHandle3"/>

    <!--    <BreakSpace label="旧件列表" :containerStyle="{ marginBottom: '10px' }" />-->
    <!--    <FilterTable-->
    <!--      ref="table1"-->
    <!--      :columns="columns"-->
    <!--      :params="fetchParams"-->
    <!--      :dataSource="dataList"-->
    <!--      :datakey="'items'"-->
    <!--      :onColumnsChange="columns => (this.columns = columns)"-->
    <!--      :onRowSelectChange="selectChange"-->
    <!--      selectionType="single"-->
    <!--      height="auto"-->
    <!--      :isPagination=false-->
    <!--      :isSelectColumn=false-->
    <!--    >-->
    <!--    </FilterTable>-->
    <!--    <div style="padding-top: 3rem;"></div>-->
    <!--    <BreakSpace label="操作记录" :containerStyle="{ marginBottom: '10px' }" />-->
    <!--    <FilterTable-->
    <!--      ref="table2"-->
    <!--      :columns="caozuojilucolumns"-->
    <!--      :params="fetchParams"-->
    <!--      :dataSource="dataList1"-->
    <!--      :datakey="'items'"-->
    <!--      :onColumnsChange="columns => (this.columns = columns)"-->
    <!--      :onRowSelectChange="selectChange"-->
    <!--      selectionType="single"-->
    <!--      height="auto"-->
    <!--      :isPagination=false-->
    <!--      :isSelectColumn=false-->
    <!--    >-->
    <!--    </FilterTable>-->
    <div style="margin-bottom: 1rem;"></div>
    <div style="padding-top: 3rem;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button type="primary" :click="saveDialog.bind()">保 存</multiuse-button>
      <multiuse-button @click="closeDialog">关 闭</multiuse-button>
    </div>
  </div>
</template>
<script>
import config from '@/assets/js/config';
import {getPartType} from '@/api/dictionary/index.js';
import {getCitys, getDistrict, getProvince, selectById, updateMaintain} from '@/api/customerRepair/customerInfo/ownerVehicleManagement';
import {dictionary} from '@/utils/dictMixin';
import {findFileByUrl} from '@/api/partsmanage/financialManagement/capitalAccount';

export default {
  props: ['rowData'],
  mixins: [dictionary],
  components: {

  },
  data() {
    return {
      saveData2: {
      },
      saveData3: {
        idCardPic: [],
        drivingLicensePic: []
      },
      cities: [],
      provinces: [],
      dataList: [],
      dataList1: [],
      visible: false,
      vin: null,
      visibleDrawer: false,
      selectDelearFlag: false,
      collapse: false,
      infoId: null,
      flterValue: {}, //参数
      //上报信息
      // columns: this.creatHeader(),
      //操作记录
      // caozuojilucolumns: this.caozuojilu(),
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中服务站
      //通知单信息
      formList1: this.createFormList(),
      formList2: this.createformListshangbao(),
      formList3: this.createFormList3(),
      saveData: null
    };
  },
  async created() {
    await this.chuqi();
    await this.chuqi2();
    // this.chuqi3();
    // this.chuqi4();
    // this.chuqi5();
    await this.getProvine();
    await this.init(this.rowData);
  },
  methods: {
    formChangeHandle1(val) {
      console.log('formChangeHandle1', val);
      this.saveData = val;
    },
    formChangeHandle2(val) {
      console.log('formChangeHandle2', val);
      this.saveData2 = val;
    },
    formChangeHandle3(val) {
      console.log('formChangeHandle3', val);
      this.saveData3 = val;
    },
    async init(val) {
      let newVar = await selectById({vin: val});

      this.editData = newVar.data;
      console.log("=== 通过ID查询结果返回 ==== ",newVar," ======");

      if (newVar.data['province']) {
        var filteredProvince = this.provinces.filter(item => item.appId === 'RL' && item.regionCode == newVar.data['province']);
        var provinceId = filteredProvince[0].regionId;
        this.cities = await getCitys(provinceId);
        this.formList2.find(item => item.fieldName === 'city').itemList = this.cities.data.map(x => ({ value: Number(x.regionCode), text: x.regionName }));
        if (newVar.data['city']) {

          var filteredCity = this.cities.data.filter(item => item.appId === 'RL' && item.regionCode == newVar.data['city']);
          let cityId = filteredCity[0].regionId;
          const district = await getDistrict(cityId);
          this.formList2.find(item => item.fieldName === 'district').itemList = district.data.map(x => ({ value: Number(x.regionCode), text: x.regionName }));

        }
      }

      this.formList1.forEach(x => {
        console.log(newVar);
        x.initialValue = newVar.data[x.fieldName];
      });
      this.formList2.forEach(x => {
        console.log(newVar);
        x.initialValue = newVar.data[x.fieldName];
      });

      //附件
      for (const x of this.formList3) {
        if (x.fieldName == 'idCardPic' || x.fieldName == 'drivingLicensePic') {
          if (newVar.data[x.fieldName] == null) {
            x.initialValue = [];
          } else {
            let realUrl = newVar.data[x.fieldName].split("?")[0]
            // let picUrl = await this.downLoadByUrl(realUrl)
            x.initialValue = [realUrl];
          }
        }else if (x.fieldName == 'fileList') {
          x.initialValue = newVar.data.fileList.map(f => ({name: f.title, url: f.fileUrl}));
        } else {
          x.initialValue = newVar.data[x.fieldName];
        }
        // console.log(newVar);
        // x.initialValue = newVar.data[x.fieldName];
      }
      //
      // //文件地址转换
      // // let tempFileArr =[];
      // // for (let i = 0; i < newVar.data.fileList.length; i++) {
      // //   let current = newVar.data.fileList[i];
      // //   let res = await findFileByUrl(current.fileUrl);
      // //   if (res) {
      // //     current.fileUrl = res.data;
      // //     tempFileArr.push(current);
      // //   }
      // // }
      // this.formList2.forEach(x => {
      //   x.initialValue = newVar.data[x.fieldName];
      //   if (x.fieldName == 'fileList') {
      //     x.initialValue = newVar.data.fileList.map((f) => ({name: f.title, url: f.fileUrl}));
      //   }
      // });
      // this.$refs.table1.$refs.pageTable.EXECUTE_INSERT(newVar.data.dtlList);
      // //回运状态是新建或已回运，查询店端员工数据55881001 55881004,紧急回运第一条保留不查店端
      // const empData = await getUserInfo();
      // let newLogList = [];
      // newVar.data.logList.forEach((x,index) => {
      //   if (newVar.data.returnType && newVar.data.returnType == 55951002 && index == 0) {
      //     //紧急回运第一条保留不查店端
      //   } else if (x.checkBy && empData && (x.checkStatus === 55881001 || x.checkStatus === 55881004)) {
      //     let userData = empData.data.find(item => item.userId == x.checkBy);
      //     if (userData) {
      //       x.checkByStr = userData.userName;
      //     }
      //   }
      //   newLogList.push(x);
      // });
      // this.$refs.table2.$refs.pageTable.EXECUTE_INSERT(newLogList);
      // // this.$refs.table2.$refs.pageTable.EXECUTE_INSERT(newVar.data.logList);
      // if(this.rowData.statusStr ==='已回运'){
      //   this.formList1.find(x => x.fieldName == 'str').hidden = false;
      //   this.formList1.find(x => x.fieldName == 'str').initialValue = this.rowData.statusStr;
      //   this.flag = false;
      // }else{
      //   this.formList1.find(x => x.fieldName == 'str').hidden = true;
      //   this.formList1.find(x => x.fieldName == 'returnStatus').hidden = false;
      // }

    },
    // 获取服务端文件 to blob
    async downLoadByUrl(url, params = {}) {
      let res = await findFileByUrl(url);
      console.log(res.data)
      return res.data;
    },
    async chuqi() {
      console.log("===== 获取下拉框数据 ====== ")
      const res = await getPartType({ type: 2117 });
      console.log("==========",res)
      if (res.resultCode == 200) {
        this.formList2.find(x => x.fieldName == 'ownerProperty').initialValue = '';
        this.formList2.find(x => x.fieldName == 'ownerProperty').itemList = res.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
      }
    },
    async chuqi2() {
      console.log("===== 获取下拉框数据 ====== ")
      const res = await getPartType({ type: 2120 });
      console.log("==========",res)
      if (res.resultCode == 200) {
        this.formList2.find(x => x.fieldName == 'ctCode').initialValue = '';
        this.formList2.find(x => x.fieldName == 'ctCode').itemList = res.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
      }
    },
    // 清空下拉框表当控件的值和下拉列表
    clearFormItem(item) {
      item.initialValue = undefined;
      item.itemList = [];
    },
    // 获取省
    async getProvine() {
      const res = await getProvince();
      this.provinces = res.data;
      this.formList2.find(item => item.fieldName === 'province').itemList = res.data.map(x => ({ value: Number(x.regionCode), text: x.regionName }));
    },
    // 获取市
    async provinceChange(regionId) {
      const province = await getProvince();
      var parentRegion = province.data.filter(item => item.appId === 'RL' && item.regionCode == regionId);
      console.log("筛选后", parentRegion);
      this.clearFormItem(this.formList2.find(item => item.fieldName === 'city'));
      this.clearFormItem(this.formList2.find(item => item.fieldName === 'district'));
      if (!regionId) return;
      this.cities = await getCitys(parentRegion[0].regionId);
      this.formList2.find(item => item.fieldName === 'city').itemList = this.cities.data.map(x => ({ value: Number(x.regionCode), text: x.regionName }));
    },
    // 获取区县
    async cityChange(regionId) {
      console.log("this.cities", this.cities);
      console.log("val", regionId);
      let city = this.cities.data.filter(item => item.appId === 'RL' && item.regionCode == regionId);
      console.log("city", city);
      this.clearFormItem(this.formList2.find(item => item.fieldName === 'district'));
      if (!regionId) return;
      const res = await getDistrict(city[0].regionId);
      this.formList2.find(item => item.fieldName === 'district').itemList = res.data.map(x => ({ value: Number(x.regionCode), text: x.regionName }));
    },
    checkCertificateNoProv(val) {
      var pattern = /^[1-9][0-9]/;
      var provs = {11: '北京', 12: '天津', 13: '河北', 14: '山西', 15: '内蒙古',21:'辽宁', 22:'吉林', 23:'黑龙江',31:'上海',32:'江苏',33:'浙江',34:'安徽',35:'福建',36:'江西',37:'山东',41:'河南',42:'湖北 ',43:'湖南',44:'广东',45:'广西',46:'海南',50:'重庆',51:'四川',52:'贵州',53:'云南',54:'*** ',61:'陕西',62:'甘肃',63:'青海',64:'宁夏',65:'***',71:'***',81:'***',82:'澳门'};
      if(pattern.test(val)) {
        if(provs[val]) {
          return true;
        }
      }
      return false;
    },
    checkCertificateNoDate(val) {
      var pattern = /^(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)$/;
      if(pattern.test(val)) {
        var year = val.substring(0, 4);
        var month = val.substring(4, 6);
        var date = val.substring(6, 8);
        var date2 = new Date(year+"-"+month+"-"+date);
        if(date2 && date2.getMonth() == (parseInt(month) - 1)) {
          return true;
        }
      }
      return false;
    },
    checkCode(val) {
      var p = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9X]$/;
      var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
      var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
      var code = val.substring(17);
      if(p.test(val)) {
        var sum = 0;
        for(var i=0;i<17;i++) {
          sum += val[i]*factor[i];
        }
        if(parity[sum % 11] == code.toUpperCase()) {
          return true;
        }
      }
      return false;
    },
    checkCertificateNo(val) {
      if(this.checkCode(val)) {
        var date = val.substring(6,14);
        if(this.checkCertificateNoDate(date)) {
          if(this.checkCertificateNoProv(val.substring(0,2))) {
            return true;
          }
        }
      }
      return false;
    },
    formChangeHandle(val) {
      console.log(val);
      this.saveData = val;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    async saveDialog() {
      this.$refs.formPanel1.SUBMIT_FORM();
      this.$refs.formPanel2.SUBMIT_FORM();
      this.$refs.formPanel3.SUBMIT_FORM();

      let params = {};
      params = Object.assign({}, this.saveData, this.saveData2,  this.saveData3);

      let email = this.formList2.find(item => item.fieldName === 'email').initialValue;
      console.log('email', email);
      if (email) {
        const regex = new RegExp(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/);
        if (!regex.test(email)) {
          this.$notify.warning({ title: '提示信息', message: '邮箱不符合规范！' });
          return;
        }
      }

      let mobile = this.formList2.find(item => item.fieldName === 'mobile').initialValue;
      let contactorPhone = this.formList2.find(item => item.fieldName === 'phone').initialValue;
      const phoneRegex = new RegExp(/^1[2-9]\d{9}$/);
      const faxReg = new RegExp(/^((\d{3,4}-)|\d{3,4})\d{7,8}$/);

      if (mobile) {
        if (!phoneRegex.test(mobile)) {
          this.$notify.warning({ title: '提示信息', message: '车主手机号码不符合规范！' });
          return;
        }
      }
      if (contactorPhone) {
        if (!phoneRegex.test(contactorPhone) && !faxReg.test(contactorPhone)) {
          this.$notify.warning({ title: '提示信息', message: '联系电话号码不符合规范！' });
          return;
        }
      }

      //身份证验证
      let ctCode = this.formList2.find(item => item.fieldName === 'ctCode').initialValue;
      let certificateNo = this.formList2.find(item => item.fieldName === 'certificateNo').initialValue;
      if (ctCode && ctCode == 21201001) {
        if (certificateNo) {
          // const regex = new RegExp(
          //   /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9X]$/);
          if (!this.checkCertificateNo(certificateNo)) {
            this.$notify.warning({ title: '提示信息', message: '身份证号码不符合规范！' });
            return;
          }
        }
      }

      let zipCode = this.formList2.find(item => item.fieldName === 'zipCode').initialValue;
      if (zipCode) {
        const zipCodeReg = new RegExp(/^\d{6}$/);
        if (!zipCodeReg.test(zipCode)) {
          this.$notify.warning({ title: '提示信息', message: '邮编不符合规范！' });
          return;
        }
      }

      let fax = this.formList2.find(item => item.fieldName === 'fax').initialValue;
      if (fax) {
        if (!faxReg.test(fax)) {
          this.$notify.warning({ title: '提示信息', message: '传真不符合规范！' });
          return;
        }
      }

      //图片
      console.log(this.formList3.find(item => item.fieldName === 'idCardPic'));
      let idCardPicComp = this.formList3.find(item => item.fieldName === 'idCardPic');
      console.log("params", params);
      console.log("this.saveData3.idCardPic", this.saveData3.idCardPic);
      if (this.saveData3.idCardPic && this.saveData3.idCardPic.length > 0) {
        //新上传、有url属性，回显的没有
        if (this.saveData3.idCardPic[0].hasOwnProperty('url')) {
          params.idCardPic = this.saveData3.idCardPic[0].url;
          console.log("params.idCardPic", params.idCardPic)
        } else {
          let pic = this.saveData3.idCardPic[0];
          if (Array.isArray(pic)) {
            params.idCardPic = pic[0];
          } else {
            params.idCardPic = pic;
          }
        }
      }else {
        params.idCardPic = null;
      }

      if (this.saveData3.drivingLicensePic && this.saveData3.drivingLicensePic.length > 0) {
        //新上传、有url属性，回显的没有
        if (this.saveData3.drivingLicensePic[0].hasOwnProperty('url')) {
          params.drivingLicensePic = this.saveData3.drivingLicensePic[0].url;
          console.log("params.drivingLicensePic", params.drivingLicensePic)
        } else {
          let pic = this.saveData3.drivingLicensePic[0];
          if (Array.isArray(pic)) {
            params.drivingLicensePic = pic[0];
          } else {
            params.drivingLicensePic = pic;
          }
        }
      }else {
        params.drivingLicensePic = null;
      }

      console.log("afterParams", params);

      if (params.fileList && params.fileList.length > 0) {
        for (let i = 0; i < params.fileList.length; i++) {
          params.fileList[i].fileUrl = params.fileList[i].url;
        }
      }

      let res = await updateMaintain(params);
      console.log(res);
      if (res.resultCode === 200) {
        this.$emit('save');
        return this.$notify.success({ title: '提示信息', message: '保存成功' });
      } else {
        this.loading = false;
        this.$notify.error({ title: '提示信息', message: res.errMsg || '保存失败!' });
        // this.closeDialog();
      }
      this.loading = false;

    },
    //取消操作
    closeDialog() {
      this.$emit('close');
    }, //服务站选择页面
    SelectDelear() {
      this.selectDelearFlag = true;
    }, //关闭
    Delearclose() {
      this.selectDelearFlag = false;
    },
    //保存
    Delearsave() {
      this.selectDelearFlag = false;
      this.fetchParams = { ...this.fetchParams };
    },
    chooseOrderNo() {
      this.visible = true;
    },
    add() {},
    //车辆信息
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          disabled: true, // 置会
          readonly: true // 只读
        },
        {
          type: 'INPUT',
          label: '品牌',
          fieldName: 'brandName',
          disabled: true, // 置会
          readonly: true // 只读
        },
        {
          type: 'INPUT',
          label: '车系',
          fieldName: 'seriesName',
          disabled: true, // 置会
          readonly: true // 只读
        },
        {
          type: 'INPUT',
          label: '车型',
          fieldName: 'modelName',
          readonly: true, // 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '发动机号',
          fieldName: 'engineNo',
          readonly: true, // 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '变速器',
          fieldName: 'gearBox',
          readonly: true, // 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '电机号',
          fieldName: 'motorNo1',
          readonly: true, // 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '电池包编号',
          fieldName: 'batteryNo',
          readonly: true, // 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '销售经销商代码',
          fieldName: 'salesDealerCode',
          readonly: true, // 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '销售经销商简称',
          fieldName: 'salesDealerName',
          readonly: true, // 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'license'
        },
        {
          type: 'SELECT',
          label: '营运性质',
          fieldName: 'businessKind',
          itemList: this.createDictList('2114')
        },
        {
          type: 'DATE',
          label: '保修开始日期',
          valueFormat: 'yyyy-MM-dd',
          dateFormat: 'yyyy-MM-dd',
          fieldName: 'wrtBeginDate'
        },
        {
          type: 'DATE',
          label: '开票日期',
          valueFormat: 'yyyy-MM-dd',
          dateFormat: 'yyyy-MM-dd',
          fieldName: 'invoiceDate'
        },
        {
          type: 'DATE',
          label: '销售日期',
          valueFormat: 'yyyy-MM-dd',
          dateFormat: 'yyyy-MM-dd',
          fieldName: 'salesDate'
        },
      ];
    },
    //车主信息
    createformListshangbao() {
      return [
        {
          type: 'INPUT',
          label: '车主No',
          fieldName: 'ownerNo',
          hidden: true
        },
        {
          type: 'INPUT',
          label: '车主姓名',
          fieldName: 'ownerName'
        },
        {
          type: 'SELECT',
          label: '车主性质',
          fieldName: 'ownerProperty',
          itemList: [],
        },
        {
          type: 'INPUT',
          label: '车主手机号',
          fieldName: 'mobile'
        },
        {
          type: 'INPUT',
          label: '联系电话',
          fieldName: 'phone'
        },
        {
          type: 'SELECT',
          label: '车主性别',
          fieldName: 'gender',
          itemList: this.createDictList('1002'),
        },
        {
          type: 'SELECT',
          label: '证件类型',
          fieldName: 'ctCode',
          itemList: [],
        },
        {
          type: 'INPUT',
          label: '证件号码',
          fieldName: 'certificateNo'
        },
        {
          type: 'DATE',
          label: '生日',
          valueFormat: 'yyyy-MM-dd',
          dateFormat: 'yyyy-MM-dd',
          fieldName: 'birthday'
        },
        {
          type: 'INPUT',
          label: '传真',
          fieldName: 'fax'
        },
        {
          type: 'INPUT',
          label: '邮编',
          maxLength: 6,
          fieldName: 'zipCode'
        },
        {
          type: 'SELECT',
          label: '省',
          fieldName: 'province',
          itemList: [],
          change: val => {
            this.provinceChange(val);
            let itemList = this.formList.find(item => item.fieldName === 'province').itemList;
            // this.resetAddress(val || '', itemList);
          },
        },
        {
          type: 'SELECT',
          label: '城市',
          fieldName: 'city',
          itemList: [],
          change: val => {
            this.cityChange(val);
            // let itemList = this.formList.find(item => item.fieldName === 'city').itemList;
            // this.resetAddress(val || '', itemList);
          }
          // rules: [{ required: true, message: '请选择城市', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '区/县',
          fieldName: 'district',
          itemList: [],
          change: val => {
            let itemList = this.formList.find(item => item.fieldName === 'district').itemList;
            // this.resetAddress(val || '', itemList);
          }
          // rules: [{ required: true, message: '请选择区县', trigger: 'change' }]
        },
        {
          type: 'TEXT_AREA',
          label: '地址',
          fieldName: 'address',
          selfCols: 2,
          maxlength: 100,
          showOverflowTooltip: true
        },
        {
          type: 'INPUT',
          label: 'E_mail',
          fieldName: 'email',
          showOverflowTooltip: true,
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'remark',
          maxlength: 200,
          selfCols: 4,
          // rows: 3
        }
      ];
    },
    createFormList3() {
      return [
        {
          type: 'UPLOAD_IMG',
          label: '购车发票',
          fieldName: 'idCardPic',
          placeholder: '上传购车发票图片...',
          selfCols: 1,
          change: async val => {
            if (Array.isArray(val) && val.length > 0 && val[0].hasOwnProperty("url")) {
              console.log('change', val);
              if (val && val.length > 0) {
                // let res = await this.downLoadByUrl(val[0].url.url);
                // console.log("res", res)
                // if (res) {
                  // this.saveData3.idCardPic.push({url: res})
                  this.formList3.find(item => item.fieldName === 'idCardPic').initialValue = [];
                  this.formList3.find(item => item.fieldName === 'idCardPic').initialValue.push(val[0].url)
                  this.saveData3.idCardPic.push(val[0].url)
                  console.log("this.saveData3.idCardPic", this.saveData3.idCardPic)
                  console.log("this.saveData3", this.saveData3)
                  // this.formList3.find(item => item.fieldName === 'idCardPic').initialValue = res.data;
                  // console.log('idCardPic', this.formList3.find(item => item.fieldName === 'idCardPic'));
                //}
              }
            }
          },
          // rules: [{ required: true, message: '请上传身份证图片', trigger: 'change' }],
          upload: {
            actionUrl: `${config.uploadUrl}/api/file/oss/upload`,
            // actionUrl: `${config.uploadUrl}/api/file/v1/file/upload`,
            // actionUrl: '/api/file/oss/upload',
            // actionUrl: '/api/file/v1/file/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName: true,
            isPreview:true
          }
          // hidden: true,
          // disabled: true, //置灰
          // readonly: true // 只读
        },
        {
          type: 'UPLOAD_IMG',
          label: '行驶证',
          fieldName: 'drivingLicensePic',
          placeholder: '上传行驶证图片...',
          selfCols: 1,
          change: async val => {
            console.log('dsfsfsgfdhh', val);
            if (Array.isArray(val) && val.length > 0 && val[0].hasOwnProperty("url") ) {
              console.log('change', val);
              if (val && val.length > 0) {
                // let res = await this.downLoadByUrl(val[0].url.url);
                // console.log("res", res)
                // if (res) {
                  this.formList3.find(item => item.fieldName === 'drivingLicensePic').initialValue = [];
                  this.formList3.find(item => item.fieldName === 'drivingLicensePic').initialValue.push(val[0].url)
                  this.saveData3.drivingLicensePic.push(val[0].url)
                  console.log("this.saveData3.idCardPic", this.saveData3.drivingLicensePic)
                  console.log("this.saveData3", this.saveData3)
               // }
              }
            }
          },
          upload: {
            actionUrl: config.uploadUrl+'/api/file/oss/upload',
            // actionUrl: `${config.uploadUrl}/api/file/v1/file/upload`,
            // actionUrl: '/api/file/oss/upload',
            fixedSize: [5, 3],
            limit: 1,
            isCalcHeight: true,
            isFileName: true,
            isPreview:true
          },
          // hidden: true,
          // disabled: true, //置灰
          // readonly: true // 只读
        },
        {
          type: 'UPLOAD_FILE',
          label: '查看文件',
          fieldName: 'fileList',
          placeholder: '选择文件...',
          initialValue: [],
          // disabled: true, //置灰
          // readonly: true,// 只读
          upload: {
            actionUrl: '/api/file/oss/upload',
            limit: 10
          }
        }
      ];
    }
  }
};
</script>
<style lang="less" scoped></style>
